package com.blog.service.impl;

import com.blog.entity.comment.Comment;
import com.blog.mapper.CommentMapper;
import com.blog.service.CommentService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {

    @Resource
    private CommentMapper mapper;

    @Override
    public Integer getCommentCountByUid(Integer uid) {
        return mapper.getCommentCountByUid(uid);
    }

    @Override
    public List<Comment> getCommentsByAid(Integer aid) {
        return mapper.getCommentsByAid(aid);
    }

    @Override
    public String addComment(Comment comment) {
        return mapper.addComment(comment) > 0 ? null : "评论发表失败,请稍后再试";
    }

    @Override
    public String deleteComment(Integer cid) {
        return mapper.deleteComment(cid) > 0 ? null : "评论删除失败,请稍后再试";
    }
}
